public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
}


//不申请额外空间
class Solution {
    public String reverseLeftWords(String s, int n) {
        StringBuilder sb = new StringBuilder(s);
        reverse(sb, 0, n - 1);
        reverse(sb, n, s.length() - 1);
        reverse(sb, 0, s.length() - 1);
        return sb.toString();
    }

    void reverse(StringBuilder sb, int l, int h) {
        while (l < h) {
            char temp = sb.charAt(l);
            sb.setCharAt(l, sb.charAt(h));
            sb.setCharAt(h, temp);
            l++;
            h--;
        }
    }
}


class Solution1 {
    public String reverseLeftWords(String s, int n) {
        String left = s.substring(0, n);
        String right = s.substring(n);
        return right + left;
    }
}